package com.taptech.doufu.services;

import android.app.Activity;

import com.taptech.doufu.constant.Constant;
import com.taptech.doufu.listener.HttpResponseListener;
import com.taptech.doufu.services.personalcenter.AccountService;
import com.taptech.doufu.net.httputils.HttpRequestObject;
import com.taptech.doufu.net.httputils.HttpUtil;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import java.util.LinkedList;
import java.util.List;

public class CommentService
{

    public static final String BASE_URL = "http://" + Constant.HOST_NAME + "/index.php/comment/";
    public final static int HANDLE_PUBLISH_COMMONET = 1302;
    public final static int HANDLE_PUBLISH_REPLY = 1303;


    private static CommentService instance = new CommentService();

    private CommentService()
    {

    }

    public static CommentService getInstance()
    {
        return instance;
    }



    public void replyComment(String articleId, String commentId, String toUserId, String toReplyId, String replys, Activity acticity, HttpResponseListener listener)
    {
        HttpRequestObject request = new HttpRequestObject();
        request.setHandleType(HANDLE_PUBLISH_REPLY);
        List<NameValuePair> list = new LinkedList<NameValuePair>();
        NameValuePair value;
        value = new BasicNameValuePair("article_id", articleId);
        list.add(value);
        value = new BasicNameValuePair("uid", AccountService.getInstance().getUserUid());
        list.add(value);
        value = new BasicNameValuePair("comment_id", commentId);
        list.add(value);
        value = new BasicNameValuePair("to_uid", toUserId);
        list.add(value);
        value = new BasicNameValuePair("to_reply_id", toReplyId);
        list.add(value);
        value = new BasicNameValuePair("content", replys);
        list.add(value);
        request.setData(list);
        request.setUrl(BASE_URL + "reply");
        request.setListener(listener);
        HttpUtil.sendLockedPostRequest(request, acticity);
    }

}
